from langchain_openai import ChatOpenAI
from langchain_huggingface import HuggingFaceEmbeddings

import os

# 创建llm模型
def init_model() :
    # 模型定义
    ZHIPUAI_API_KEY = '794380a4cee054a0f96bb2844b41fd12.X4t70kph1CfmoKfT'
    BASE_PATH ='https://open.bigmodel.cn/api/paas/v4/'
    return ChatOpenAI(model_name='glm-4',temperature=.7,openai_api_key=ZHIPUAI_API_KEY,base_url=BASE_PATH)
 
# 文档向量化
def init_embeddings(model_name="google-bert/bert-base-chinese"):
    # pip install   sentence_transformers 
    os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
    return HuggingFaceEmbeddings(model_name)
